package com.superheroes.entity;

import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;

@Data
@TableName("sys_user")
public class SysUser extends Model<SysUser> implements Serializable {

    @TableId(value = "id")
    private Long id;

    @TableField("username")
    private String userName;

    @TableField("password")
    private String passWord;

    @TableField("nick_name")
    private String nickName;

    @TableField("head_img_url")
    private String headImgUrl;

    @TableField("phone")
    private String phone;

    @TableField("sex")
    private Integer sex;

    @TableField("enabled")
    private Integer enabled;

    @TableField("type")
    private String type;

    @TableField("create_time")
    private Date createTime;

    @TableField("update_time")
    private Date updateTime;

    @TableField("only_code")
    private String onlyCode;

    public void setId(Long id) {
        if(id==null || id==0L)
        {
            Snowflake snowflake = IdUtil.getSnowflake(1, 1);
            this.id  = snowflake.nextId();
        }else
            {
                this.id = id;
            }
    }
}
